﻿using FI.Security;
using Sample.BusinessComponent;
using Sample.Common.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Sample.Web.Areas.Admin.Controllers
{
    public class SitemapController : BaseController<SitemapBC>
    {
        // GET: Sitemap
        public ActionResult Index()
        {
            var list = this.Service.GetSitemaps();

            return View(list);
        }

        // GET: Sitemap/Details/5
        public ActionResult Details(int id)
        {
            return View();
        }

        // GET: Sitemap/Create
        public ActionResult Create()
        {
            return View();
        }
        // POST: Sample/Create

        public ActionResult Import(SitemapModel sitemap)
        {
            if (ModelState.IsValid)
            {
                this.Service.AddSitemap(sitemap);

                return RedirectToAction("Index");

            }
            //validation failed, return model
            return View(sitemap);

        }
        // POST: Sitemap/Create
        [HttpPost]
        public ActionResult Create(SitemapModel sitemap)
        {
            try
            {
                this.Service.AddSitemap(sitemap);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: Sitemap/Edit/5
        public ActionResult Edit(int id)
        {
            return View();
        }

        // POST: Sitemap/Edit/5
        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: Sitemap/Delete/5
        public ActionResult Delete(int id)
        {
            return View();
        }

        // POST: Sitemap/Delete/5
        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
